<!-- 该组件需自行实现, 此处只是示例 -->
<template>
	<!-- 为性能缘故, 当tab项多时, 请尽量不要删除 v-if="show" -->
	
	<view v-if="show">
		<view class="container">
			<!-- <QS-P height="20rpx"></QS-P> -->
			<view class="coupon" v-for="(item, index) in list" :key="index" @tap="navigateTo('my.orderDetail.coupon', { id: item.id })">
				<view class="flex_1 flex_row">
					<view class="flex_column_c_c" style="width: 160rpx;">
						<view class="text-tabel-cell-bottom">
							<text class="QS-text mini weight" style="color: #F52F50;">￥</text>
							<text class="QS-text weight" style="color: #F52F50;font-size: 36rpx;">{{item.couponAmount}}</text>
						</view>
						<text class="QS-text mini-xxx">{{item.couponFullAmount == 0?'无门槛':`满${item.couponFullAmount}可用`}}</text>
					</view>
					<view class="flex_1 flex_column_between_none padding-rpx_25 coupon-right">
						<view class="flex_row">
							<text class="QS-text mini weight flex_1 width_0 text-overflow_ellipsis">{{item.couponName}}</text>
						</view>
						<text class="QS-text mini-xx">{{item.couponRemark}}</text>
						<text class="QS-text mini-xxxx color_888888">{{item.activityDateStart | filterDycTime('yyyy.MM.dd hh:mm')}}-{{item.activityDateEnd | filterDycTime('yyyy.MM.dd hh:mm')}}</text>
					</view>
				</view>
				<view class="flex_column_c_c" style="width: 160rpx;">
					<block v-if="item.payStatus == 0">
						<block v-if="Number(item.integrateAmount) && Number(item.fullAmount)">
							<view class="flex_row_none_c">
								<text class="QS-text mini-xxx weight">{{item.integrateAmount}}</text>
								<text class="QS-text mini-xxx">积分</text>
							</view>
							<text class="QS-text mini-xxx weight">￥{{item.fullAmount}}</text>
							<view class="payBtn">
								<text class="QS-text mini-xxx color_ffffff">待付款</text>
							</view>
						</block>
						<block v-else-if="Number(item.integrateAmount) && !Number(item.fullAmount)">
							<view class="text-tabel-cell-bottom">
								<text class="QS-text large weight">{{item.integrateAmount}}</text>
								<text class="QS-text mini-xxxx">积分</text>
							</view>
							<view class="payBtn">
								<text class="QS-text mini-xxx color_ffffff">待付款</text>
							</view>
						</block>
						<block v-else-if="!Number(item.integrateAmount) && Number(item.fullAmount)">
							<view class="text-tabel-cell-bottom">
								<text class="QS-text mini-xxx weight">￥</text>
								<text class="QS-text large weight">{{item.fullAmount}}</text>
							</view>
							<view class="payBtn">
								<text class="QS-text mini-xxx color_ffffff">待付款</text>
							</view>
						</block>
						<block v-else>
							<view class="payInfo">
								<text class="QS-text mini-xxx color_888888">已领取</text>
							</view>
						</block>
					</block>
					<block v-if="item.payStatus == -1">
						<view class="payInfo">
							<text class="QS-text mini-xxx color_888888">支付失败</text>
						</view>
					</block>
					<block v-if="item.payStatus == 1">
						<block v-if="item.refundStatus == 1">
							<view class="payInfo">
								<text class="QS-text mini-xxx color_888888">已退款</text>
							</view>
						</block>
						<block v-else>
							<image :src="`${$preStaticPath}/image/done.png`" mode="aspectFill" class="dyc-img-done"></image>
						</block>
					</block>
				</view>
			</view>
		</view>
		<!-- 列表状态展示 -->
		<view class="list-status-box">
			<listStatus :statusText="statusText" @click="getList(false, true, false)"></listStatus>
		</view>
	</view>
</template>

<script>
	import {
		doPageDemand
	} from '@/QS-UI-CONFIG/js/pageDemand.js';
	export default {
		props: {
			tabItem: {
				type: [Object, String],
				default () {
					return {}
				}
			},
			index: {
				type: [String, Number],
				default: ''
			},
			current: {
				type: [String, Number],
				default: ''
			},
			type: {
				type: String,
				default: ''
			},
			show: {
				type: Boolean,
				default: false
			},
			readyRefresh: {
				type: [Boolean, String],
				default: false
			},
			refreshDistance: {
				type: Number,
				default: 0
			},
			customData: {	//由最外部传入的自定义数据
				type: [Object, String, Number, Array, Boolean],
				default: ()=>{ return {} }
			}
		},
		data() {
			return {
				list: [],
				sendData: {
					page: 1,
					firstType: 3
				},
				statusText: {},
			}
		},
		methods: {
			init(refresh) {	//若是用户触发下拉刷新则refresh为true
				this.getList(refresh, false, false);
				// if (refresh) _this.$emit('refreshEnd', true);
			},
			getList(refresh, doEvent, force) {
				console.log('调用获取列表方法 ')
				let _this = this;
				this.sendData.secondType = this.tabItem.type;
				doPageDemand.call(_this, {
					getDataFn: uni.$qs.myApis.common.getUserOrderList, //获取数据的方法
					successEnd() {
						if (refresh) _this.$emit('refreshEnd', true);
					},
					fail() {
						console.log('访问接口失败');
						if (refresh) _this.$emit('refreshEnd', false);
					}, //接口访问失败回调

					sendDataName: 'sendData', //携带数据字段名称
					pageNumName: 'page', //携带数据中的页数字段名称
					pageSizeName: 'pageSize', //携带数据中的条数字段名称

					checkLastPageMode: 'page', //判断是否是最后一页的逻辑标识, 用于逻辑判断, 目前默认有两个参数 size: 判断条数, page: 判断页数, 默认为size
					newDatafields: 'rows', //接口访问成功后获取列表数据字段名称, 可用. 链式获取
					dataLastPageName: 'pages', //接口访问成功后数据中的最大页数字段名称, 可用. 链式获取
					sizeName: false, //接口访问成功后数据中条数字段名称, 可用. 链式获取

					setName: 'list', //页面中列表数据字段名称, 如果在页面中分别有两个或两个以上列表使用该js, 则页面中需区分传入, 否则可以忽略
					statusTextName: 'statusText', //页面中列表状态字段名称, 如果在页面中分别有两个或两个以上列表使用该js, 则页面中需区分传入, 否则可以忽略
					lastPageName: false, //页面中最后一页字段名称, 如果在页面中分别有两个或两个以上列表使用该js, 则页面中需区分传入, 否则可以忽略
					waitingName: false, //页面中获取数据等待字段名称, 如果在页面中分别有两个或两个以上列表使用该js, 则页面中需区分传入, 否则可以忽略

					refresh, //刷新标识, 若为true则会将携带数据中的页数重置为1
					force, //强制标识, 若为true则会忽略等待标识为true时的跳过操作
					doEvent, //进入状态判断标识, 若为true则会进入判断列表status而进行相应操作

					noDataText: false, //访问接口后若数据长度为0则可自定义为空时文字

					refreshClear: false, //刷新时是否清空数据
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	.container{
		padding: 25rpx;
	}
	.coupon{
		border-radius: 10rpx;
	}
	.payBtn{
		padding: 6rpx 18rpx;
		border-radius: 100px;
		background-color: #F52F50;
		margin-top: 12rpx;
		display: flex;
		flex-direction: row;
		justify-content: center;
		align-items: center;
		line-height: normal;
	}
	.payInfo{
		padding: 6rpx 16rpx;
		border-radius: 100px;
		background-color: #F2F2F2;
		display: flex;
		flex-direction: row;
		justify-content: center;
		align-items: center;
		line-height: normal;
	}
</style>
